//
//  commondef.h
//  tcpoctest
//
//  Created by gump on 10/19/12.
//  Copyright (c) 2012 gump. All rights reserved.
//

#ifndef tcpoctest_commondef_h
#define tcpoctest_commondef_h
typedef struct Packet
{
    unsigned char *data;
    int           length;
}PACKET;

enum MainIndex
{
    ID_MI_HB = 1,       //heartbeat
    ID_MI_CONNECT,      //be connect
    ID_MI_CLOSE,        //be close
    ID_MI_CONFIG = 10,       //be config
    ID_MI_LOGIN = 11,        //be login
    ID_MI_ADDFIREND = 12,
    ID_MI_PERSONINFO = 13,
    ID_MI_CHAT = 16,
    ID_MI_QUITLOGIN = 22,
    ID_MI_LOCATION = 14,
    ID_MI_LOGINOTHER = 99,
    ID_MI_DRIVELOC = 21,
    ID_MI_OFFLINEMSG = 17,//off line message
    ID_MI_HEADIMAGE = 23,//check head image
    ID_MI_LOGINWITHPP = 31,//login with pp num
    ID_MI_REPORT = 41,//report
    ID_MI_FIRENDCIRCLE = 74,//firend circle
    ID_MI_VERSION = 88,//versions
    ID_MI_VERPUTH = 75,//version puth
    ID_MI_ONLINE = 15,//online people
    ID_MI_GIFT = 26,//gift
    ID_MI_RANKLIST = 27,//ranking list
    ID_MI_TASK = 65,//task
    ID_MI_MSGRECEIPT = 100,//message receipt
    ID_MI_TELEPATHY = 51,//telepathy
};

enum ConfigMessage
{
    CM_SUCCESS = 1,
    CM_FAIL = 2,
    CM_DIVCEFULL = 3,//设备已注册5个账户
};

enum LoginFailMessage
{
    LFM_SUCESS = 1,
    LFM_MAIL = 2, //没有此用户
    LFM_PS = 3,//密码错误
    LFM_MAILLOCK = 4,//账户被封
    LFM_DIVCELOCK = 5,//设备被封
    LFM_DIVCECHANGE = 6,//更换设备
};

enum NetState
{
    NETS_CONNECT,
    NETS_TIMEOUT,
    NETS_BREAK,
};

enum PersonalInfo
{
    PI_REQUEST = 1,
    PI_SETNAME = 3,
    PI_SETPS = 2,
    PI_SETSEX = 4,
    PI_SETAGE = 5,
    PI_SETPC = 6,
    PI_SETCHECK = 7,
    PI_SETREPLYADD = 8,
    PI_REQUESTFIREND = 10,
    PI_BLACKCOUNT = 14,
    PI_REQUESTBLACK = 15,
    PI_SETSIGN = 9,//设置个性签名
    PI_SETHI = 11,// set head image
    PI_SETMAIL = 17,// set mail
    PI_READCOIN = 18,// read coin
    PI_TOKEN = 38,//推送token
    PI_DISTRO = 24,//是否免打扰
};

enum AddFirendIndex
{
    AFI_SUCESS = 1,//recive 1,请求添加好友成功 发送 1  查询好友
    AFI_SEARCH = 2,//受到2 关注成功 发送 2 添加关注
    AFI_BECARE = 3,//受到3 被XX关注
    AFI_READCARELENGTH = 10,//发送  读取关注人的长度
    AFI_SEARCHSUCESS = 29,//受到 查询成功
    AFI_SEARCHFAIL = 30,//受到  查无此人
    AFI_CHECKSUCCESS = 9,//受到 通过验证 send  search pp number
    AFI_DELETEF = 6,//发送 删除好友
    AFI_SEARCHPPFAIL = 69,
    AFI_SEARCHPPSUCCESS = 70,
    AFI_CARELENGTH = 11,//返回 ，关注人的长度
    AFI_READCAREINFO = 23,//读取已关注的人
    AFI_GETCAREINFO = 24,//返回 12char(1),24char(1),[用户名长度char(1),用户名char(x)]*N
    AFI_BECARELENGTH = 15,//读取被关注人的长度
    AFI_GETBECARELENGTH = 16,//返回已被关注长度
    AFI_READBECAREINFO = 33,//读取被关注的人
    AFI_GETBECAREINFO = 34,//返回被关注人信息
    AFI_SENDDELETECARE = 5,//发送 取消关注
};

enum ViewID
{
    VI_SEARCHFIREND,//search firend
    VI_HELP,
    VI_HELP_WEB,
    VI_SETNAME,//set name
    VI_SETPS,
    VI_CHAT,
    VI_NULL,
    VI_LOGIN,
    VI_FORGET,
    VI_PERSONINFO,
    VI_CONFIGFIVE,
    VI_DEFAULT,
    VI_CONFIGFIRST,
    VI_SETSIGN,
    VI_USERINFO,
    VI_NEARPEOPLE,
    VI_CONFIGTWO,
    VI_CHATIMAGE,//聊天大图
    VI_SETMAIL,
    VI_XX,//xx view
    VI_FIRENDCIRCLE,//碰碰圈
    VI_WRITESTATUS,//发布新动态
    VI_STATUSCOMMENTS,//查看动态回复
    VI_PERSONALSTATUS,//个人空间
    VI_COMMENT,//朋友圈评论页面
    VI_ONLINEP,//在线的人界面
    VI_GIFTLIST,//礼物列表
    VI_GIFTLISTINFO,//礼物内容
    VI_GIFT_SEND,//赠送礼物
    VI_GIFT_SHOW,//显示礼物
    VI_GIFT_STROAGE,//礼物仓库
    VI_RANKLIST,//排行榜
    VI_RECHARGE,//充值
    VI_TASK,//任务
    VI_PURCHASE,//iap充值
    VI_SET_NEWS,//设置通知消息界面
    VI_PURCHASE_SELECT,//充值选择界面
    VI_SHOP,//商城
    VI_LOVE,//一见钟情
    VI_TELEPATHY,//一见钟情
    VI_COMPLETEINFO,//完善信息
    VI_TELEPATHY_T,//心电感应
};

enum RelationShip
{
    RS_STRANGER,//陌生人
    RS_FIREND,//好友
};

enum XMMessageType
{
    XMMT_BECARE,//被关注
    XMMT_CHAT,//收到聊天消息
};

enum SetModifyType
{
    SMT_NAME,
    SMT_AGE,
    SMT_SEX,
    SMT_PC,//province city
    SMT_CHECK,
    SMT_REPLYADD,
};

enum ChatType
{
    CT_TEXT = 1,
    CT_IMAGE = 2,
    CT_VOICE = 3,
    CT_SYSTEM = 4,//受到10000消息
    CT_TELEPATHY = 5,
    CT_BACK = 16,
    CT_GIFT = 100,
    CT_ALREADYSEND = 230,
    CT_ALREADYREAD = 229,
    CT_REJECT = 227,
    CT_SENDREAD = 228,
};

enum GameState
{
    GS_WITENEAR,//等待附近的人
    GS_NULL,
    GS_WITENEAROVER,
    GS_CHAT,
    GS_PERSONINFO,
};

enum RecordState
{
    RS_START,
    RS_BEGIN,
    RS_OVER,
    RS_NULL,
};

enum UICommand
{
    UC_CONFIGFAIL,
    UC_SHOWMAIN,
    UI_LOGINFAIL,
    UI_UPDATEFIRENDV,
    UI_SEARCHFIREND,
    UI_SEARCHFIRENDHEAD,
    UI_SEARCHFAIL,
    UI_ADDFIRENDSUCCESS,
    UC_DELETEFIREND,
    UC_RECIVECHECK,
    UC_REGISTUSEREXIST,
    UC_REGISTUSERSUCCESS,
    UC_UPDATASYSTEMLIST,
    UC_UPDATEPI,//update person info
    UC_SETSUCCESS,//set success
    UC_SETVIEW_SETFAIL,//set fail
    UC_UPDATEBAFINFO,//updata be add firend info
    UC_UPDATACHAT,//update chat list
    UC_LOGINOTHER,
    UC_UPDATENEARPEOPLE,//near people
    UC_LOCALLOGIN,//locally login  for:EnterForeground
    UC_REFRESHCURVIEW,//refresh current view
    UC_ONLINEP_CAMPELELOADING,//请求完数据
    UC_SETBADGE,
    UC_WARNINGNET,//net break warning
    UC_WARNINGSERVER,//server break warning
    UC_DELETECACHEOVER,//delete cache over
    UC_REPORTSUCCESS,//举报成功
    UC_READBIGSUCCESS,//读大头像url成功
    UC_PROMPT_LOGIN,//显示登陆成功提示
    UC_FIRCIR_SENDNEWFAIL,//朋友圈发布太频繁
    UC_FIRCIR_SENDNEWSUCCESS,//朋友圈发布信息成功
    UC_FIRCIR_UPDATESENDHUD,//朋友圈更新提示语言
    UC_FIRCIR_COMMENTSUCCESS,//朋友圈发送评论成功
    UC_FIRCIR_COMMENTFAIL,//朋友圈评论失败
    UC_FIRCIR_PYQ_BEGINDEL,//朋友圈开始删除动态
    UC_FIRCIR_PYQ_ENDDEL,//朋友圈结束删除动态
    UC_FIRCIR_PER_BEGINDEL,//个人动态界面开始删除动态
    UC_FIRCIR_PER_ENDDEL,//个人动态界面结束删除动态
    UC_FIRCIR_STATE_PACKUP,//朋友圈界面收起动态
    UC_FIRCIR_BADGE,//显示新消息提示
    UC_ALERTVERSION,//提示版本更新
    UC_ONLINEPEOBACK,//获得在线人数
    UC_ONLINEP_INITSWITCH,//初始化在线显示
    
    UC_GIFT_GETLIST,//获得礼物链表返回
    UC_GIFT_REFRESHLIST,//刷新礼物列表
    UC_GIFT_REFRESHINFO,//刷新礼物内容显示
    UC_GIFT_SENDBACK,//赠送礼物返回
    
    UC_CHAT_POPGIFTMENU,//弹出聊天界面礼物菜单
    UC_CHAT_REFRESH,//刷新聊天界面
    UC_CHAT_POPRESENDMENU,//弹出重发菜单
    UC_CHAT_TELEPATHYFAIL,//心电感应失败
    
    UC_RANKLIST_RECEIVE,//排行榜接到榜单消息
    
    UC_TASK_COMPLETE,//任务完成提示
    
    UC_TELEP_GETCANDLE,//心电感应得到蜡烛
    UC_TELEP_GETLIGHT,//点亮返回
};

enum LogicCommand
{
    LC_HEADJUMP,
    LC_SENDCONFIG,
    LC_SEARCHFRIEND,
    LC_ADDFIREND,
    LC_DELETEFIREND,
    LC_CAR,//check already register
    LC_SENDPERSONINFO,//send request person info
    LC_SETNAME,
    
    LC_UPDATEUIDB,//update user info database
    LC_SETSEX,
    LC_SETAGE,
    LC_SETPS,//set password
    LC_SETHEADIMAGE,// set head image
    LC_SETSIGN,
    LC_SETPC,//set provice and city
    LC_SETMAIL,//set mail
    
    LC_BACKGROUND,
    LC_FOREGROUND,
    LC_SETCHECK,
    
    LC_LOGINBYPP,
    LC_LOGINBYUI,
    LC_LOGINAUTO,
    
    LC_SENDTEXT,
    LC_SENDIMAGE,
    LC_SENDVOICE,
    LC_NEARPEOPLE,
    LC_SENDREQUESTINFO,
    LC_SENDREQUESTHI,
    
    LC_DELETECACHE,
    LC_REPORT,//举报
    LC_NET_RECONNECT,
    LC_FCR_DOWNLOAD,//下载朋友圈资源
    LC_FCR_GETGBI,//获取朋友圈背景图
    LC_FCR_SENDBGI,//发送朋友圈背景图
    
    LC_READVER,//读取版本
    
    LC_GIFT_DOWNIMAGE,//下载礼物类别图片
    LC_GIFT_DOWNGIFTIMAGE,//下载礼物显示图片
    LC_FIR_DELNEW,//删除动态
    
    LC_DB_GIFT_INIMAGEPATH,//数据库 礼物  插入图片路径
    LC_DB_GIFT_INMUSICPATH,//数据库 礼物  插入音乐路径
    
    LC_CHAT_PROCESSMSG,//处理未读消息
    LC_CHAT_MODIFYSTATE,//更改消息
    
    LC_BIGIMAGE_SEARCH,//查找大头像
};

enum GameModuleState
{
    GMS_CONFIG,
    GMS_LOGIN,
    GMS_MAIN,
    GMS_NULL,
    GMS_CHAT,
    GMS_PERSONINFO,
    GMS_CHANGEGROUND,//切后台状态
    GMS_GIFT,
};

enum FileType
{
    FT_HEADIMAGE,
    FT_AUDIO,
    FT_CHAT,
    FT_FIRCIR,//firend circle
    FT_FCBGI,//firend circle background image
    FT_GIFT,//gift
};

enum ProcessRequestCheck
{
    PRC_UNPROCESS,
    PRC_AGREE,
    PRC_REFUSE,
};

enum ViewDirection
{
    VD_LEFT,
    VD_RIGHT,
    VD_NULL,
};

enum UpdateUserType
{
    UUT_NAME,
    UUT_AGE,
    UUT_SEX,
    UUT_PROVINCE,
    UUT_CHECK,
    UUT_SIGN,
    UUT_ALL,
    UUT_PS,
    UUT_HIURL,//head image url
    UUT_PPNUM,
    UUT_HEADIMAGE,
    UUT_SELFMAIL,//self mail
    UUT_COIN,
    UUT_STRCOIN,//金币字符串
    UUT_DISTRO,//是否免打扰
    UUT_SOUND,//是否播放声音
};

enum CheckProcessType
{
    CPT_NULL,
    CPT_REFUSE,
    CPT_ACCEPT,
};

enum LoginType
{
    LT_PP,
    LT_MAIL,
};

enum ViewLogicType
{
    VLT_BEGIN,
    VLT_WAIT,
    VLT_END,
    VLT_NULL,
};

//near people Filter
enum NPFilterType
{
    NTF_ALL = 3,
    NTF_MALE = 1,
    NTF_FEMALE = 2,
};

enum FirendCircleIndex
{
    FC_NEW = 10,//获取好友最新动态GUID
    FC_ONE = 9,//获取X用户某一条动态
    FC_ALLCOMMENT = 12,//获取某动态所有评论
    FC_SENDNEW = 1,//发布动态
    FC_ADDPICTURE = 2,//添加图片
    FC_SENDCOMMENT = 11,//发布评论
     FC_GETNEWS = 15,//新动态通知
    FC_GETCOMMENT = 14,//评论通知
    FC_SETBGIMAGE = 25,//设置背景图
    FC_GETBGIMAGE = 24,//读取背景图
    FC_GETNEWLENGTH = 7,//获取X用户动态长度
    FC_GETNEWID = 8,//获取X用户动态ID
    FC_DELNEW = 5,//删除一条动态
    FC_RECDELNEW = 16,//接到删除通知
};

enum FirendCircleGetType
{
    FCG_ONE_TEXT = 1,//获取朋友圈个人文字信息
    FCG_ONE_SOUND = 2,//获取朋友圈个人声音信息
};

enum HeadImageIndex
{
    HII_BIG = 24,
};

enum CommentState
{
    CS_NULL,
    CS_SUBMIT,
    CS_SOUND,
};

enum TheOrder
{
   ORDER_ASC,
    ORDER_DES,
};

enum NetTurnType
{
    NTT_BIG2SMALL,
    NTT_SMALL2BIG,
    NTT_NULL,
};

enum VersionType
{
    VT_ANDROID = 1,
    VT_IOS = 2,
};

enum OnLineOrderType
{
    OLOT_MALE,
    OLOT_FAMALE,
    OLOT_NULL,
};

enum GiftIndex
{
    GI_GET = 7,//读取礼物分类
    GI_LISTLENGTH = 1,//读取礼物ID清单长度
    GI_LIST_ID = 2,//读取礼物ID清单ID
    GI_INFO = 8,//读取礼物详细信息
    GI_SEND = 3,//赠送礼物
    GI_RECEIVENOTI = 4,// 接收礼物通知
    GI_GIFT_STORAGE = 5,// 读礼物仓库
};

enum ViewGameState
{
    VGS_START,
    VGS_NULL,
};

enum GiftSendBackState
{
    GSBS_SUCCESS = 1,
    GSBS_LESSCOIN = 2,
    GSBS_DOWN = 3,
};

enum RankListIndex
{
    RLI_RICH_DAY = 1,
    RLI_RICH_WEEK = 2,
    RLI_RICH_MONTH = 3,
    RLI_RICH_QUARTER = 4,
    RLI_RICH_YEAR = 5,
    
    RLI_GLAMOUR_DAY = 6,
    RLI_GLAMOUR_WEEK = 7,
    RLI_GLAMOUR_MONTH = 8,
    RLI_GLAMOUR_QUARTER = 9,
    RLI_GLAMOUR_YEAR = 10,
};

enum TaskIndex
{
    TASK_QUERY = 1,//查询
    TASK_COMPLETE = 2,//完成
};



#define HEAD_LENGTH sizeof(int)
#define BUFFER_LENGTH   1100000
#define STREAM_LENGTH   3300000

#define JPG_COMPRESS_RATE   0.5
#define SEND_SOCKET_MAX     2048

int   WINDOW_WIDTH;     //window width
int   WINDOW_HIGTH;     //window higt

#define BACKBTN_X       4
#define BACKBTN_Y       20
#define BACKBTN_WIDTH   28
#define BACKBTN_HIGH    28
#define CONTINUE_X      283
#define CONTINUE_Y      20

#define BALLOONSIZE 5.0f
#define STATESIZE   7.0f

#define NEXTBTN_WIDTH   70
#define NEXTBTN_HIGH    30

#define IP_PORT         9527
#define IP_IP           "192.168.255.106"
#define IP_IDN          "210.14.145.121"//内网
//#define IP_IDN          "peng.peng7.net"//外网

//login protocol length
#define MAIL_PL         32 //mail 
#define PS_PL           32 //password
#define NAME_PL         32 //name
#define SEX_PL          1  //sex
#define AGE_PL          1  //age
#define HEARTBEAT_NUM   250 //heart beat number
#define LOGIC_INTERVAL  1.0  //logic interval
#define UI_TIMERINTERVAL    0.1f
#define CHAR_PL         sizeof(char)  //main index
#define kDuration       0.3 //动画持续时间
#define INPUTBG_WIDTH   147
#define INPUTBG_HIGTH   20
#define INT_PL          sizeof(int)
#define ACCESS_INTERVAL 30
#define WAIT_TIMMER     30
#define NATIVEBAR_HIGTH 20
#define NEARPEOPLE_VISIT_TIME   100.0f
#define SMALL_HEAD_IMAGE    200
#define BIG_HEAD_IMAGE      640

#define GIFT_VIEW_WIDTH     80
#define GIFT_VIEW_HIGHT     120

#define SEQUENCE_MAX                2147483648
#define INIT_MYMAIL                 @""        //初始邮箱字段
#define NAME_LIMITE_LENGTH          30          //昵称限制长度
#define UPDATE_BIGIMAGE_INTERVAL    60.0f       //更新头像间隔

#define VERSION_STRING              @"1.0"    //版本字符串

#define CELL_BG_COLOR               [UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0] //cell背景颜色
#define VIEW_BG_COLOR               [UIColor colorWithRed:1/255.0 green:63/255.0 blue:108/255.0 alpha:1.0] //cell背景颜色
#define TITLE_BAR_FONT              [UIFont boldSystemFontOfSize:20] //标题栏字体大小
#define TITLE_BAR_COLOR             [UIColor whiteColor] //标题栏的字体颜色
#define TOPBAR_HIGHT                44
#define CENTER_CELL_TITLE_FONT      [UIFont boldSystemFontOfSize:16.5]   //个人信息标题字号
#define BLOD_CELL_TITLE_FONT        [UIFont fontWithName:@"Helvetica-Bold" size:16] //个人加粗
#define SMALL_CELL_TITLE_FONT       [UIFont systemFontOfSize:14]   //个人信息标题字号
#define CENTER_CELL_CONTENT_FONT    [UIFont systemFontOfSize:16]   //个人信息输入内容字号
#define INPUT_TITLE_FONT            [UIFont boldSystemFontOfSize:16] 
#define CHATVIEW_INPUTBAR_HEIGHT    44
#define CHATVIEW_VOICEBAR_HEIGHT    37
#define CHATVIEW_INPUTBAR_COLOR     [UIColor colorWithRed:227/255.0 green:235/255.0 blue:237/255.0 alpha:1.0] //聊天输入框背景

#define COLOR_CHATSTATE_FAIL        [UIColor colorWithRed:230/255.0 green:30/255.0 blue:30/255.0 alpha:1.0] //失败  被屏蔽
#define COLOR_CHATSTATE_SENDING     [UIColor colorWithRed:80/255.0 green:165/255.0 blue:195/255.0 alpha:1.0] //发送中
#define COLOR_CHATSTATE_SEND        [UIColor colorWithRed:235/255.0 green:120/255.0 blue:55/255.0 alpha:1.0] //已发送 已送达
#define COLOR_CHATSTATE_READ        [UIColor colorWithRed:110/255.0 green:220/255.0 blue:75/255.0 alpha:1.0] //已阅读

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)


#endif

#define CUSTOMPATH @"/Users/maleyi/Documents/"
//#define CUSTOMPATH @"/gutaoworkspace/iphoneproject/finendcar/ggsvn/trunk/"
//#define CUSTOMPATH @"/Users/Shared/"